﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace ProjectSem40701.Util
{
    public class GetActiveRoundID
    {
        /// <summary>
        /// Lay ve RoundID
        /// </summary>
        /// <param name="examID"></param>
        /// <returns></returns>
        public int RoundID(int examID)
        {
            int roundID = -1;
            try
            {
                MainDataset.RoundTableAdapters.tbl_RoundTableAdapter dpRoundActive = new
                  MainDataset.RoundTableAdapters.tbl_RoundTableAdapter();
                DataTable dttblRoundActive =
                    dpRoundActive.Get_tbl_Round_Select_All_Active_By_ExamID(examID);
                if (dttblRoundActive.Rows.Count > 0)
                {
                    roundID = Convert.ToInt32(dttblRoundActive.Rows[0]["RoundID"].ToString());
                }
                return roundID;
            }
            catch
            {
                return -1;
            }
        }
        /// <summary>
        /// Lay ve roundStartTime
        /// </summary>
        /// <param name="examID">examID</param>
        /// <returns>roundStartTime</returns>
        public string RoundStartTime(int examID)
        {
            string roundStartTime = String.Empty;
            try
            {
                MainDataset.RoundTableAdapters.tbl_RoundTableAdapter dpRoundActive = new
                  MainDataset.RoundTableAdapters.tbl_RoundTableAdapter();
                DataTable dttblRoundActive =
                    dpRoundActive.Get_tbl_Round_Select_All_Active_By_ExamID(examID);
                if (dttblRoundActive.Rows.Count > 0)
                {
                    roundStartTime = dttblRoundActive.Rows[0]["RoundStartTime"].ToString();
                }
                return roundStartTime;
            }
            catch
            {
                return String.Empty;
            }
        }
        /// <summary>
        /// Tra ve mot chuoi string bieu thi duration cua vong thi
        /// </summary>
        /// <param name="examID"></param>
        /// <returns></returns>
        public string roundDuration(int examID)
        {
            string roundDuration = String.Empty;
            try
            {
                MainDataset.RoundTableAdapters.tbl_RoundTableAdapter dpRoundActive = new
                  MainDataset.RoundTableAdapters.tbl_RoundTableAdapter();
                DataTable dttblRoundActive =
                    dpRoundActive.Get_tbl_Round_Select_All_Active_By_ExamID(examID);
                if (dttblRoundActive.Rows.Count > 0)
                {
                    roundDuration = dttblRoundActive.Rows[0]["roundDuration"].ToString();
                }
                return roundDuration;
            }
            catch
            {
                return String.Empty;
            }
        }
    }
}
